package Play;

import Book.book;
import Book.booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dell
 * Date: 2023-11-29
 * Time: 18:19
 */
public class delbook implements Feature {
    @Override
    public void work(booklist Book) {
        System.out.println("deibook");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名");
        String name = scanner.nextLine();
        int a=-1;
        int count = Book.getBooksize();
        for (int i = 0; i < count; i++) {
            book Books = Book.getBook(i);
            if (Books.getName().equals(name)) {
                System.out.println("找到了");
                System.out.println(Books);
                a=i;
                System.out.println("开始删除");
                System.out.println(name);
                break;
            }
        }
        if (a==count){
            System.out.println("没找到");
        }else{
            for (int j=a;j<count-1;j++){
                book book1=Book.getBook(j+1);
                Book.setterBook(j,book1 );
            }
            Book.setBooksize(count-1);
        }
    }
}